package topuc.com.mvp.model;


import android.os.Handler;
import android.os.Message;

import topuc.com.mvp.inter.CallBack;

/**
 * Created by apls on 2018/11/23.
 */
public class IModel {

    private CallBack callBack;

    public IModel(CallBack callBack){
        this.callBack=callBack;
    }

    private Handler handler=new Handler() {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            callBack.onRequest((String) msg.obj);
        }
    };

    public void getRequest(){

        new Thread(new Runnable() {
            @Override
            public void run() {

                try {
                    Thread.sleep(2000);

                    Message msg=handler.obtainMessage();
                    msg.obj="网络上获取的数据";
                    handler.sendMessage(msg);

                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).start();
    }

}
